//index.js
//获取应用实例
const app = getApp()
const Pager = require('components/aotoo/core')


const adpater = (data) => {
  return data.map(item => {
    return {
      dot: [{
        title: {
          title: '香港机场坐飞机，有120元港币的机场税退税香港机场坐飞机退税？',
          itemClass: 'title-default no-lh-x'
        },
        body: [
          {
            dot: [{
              title: '香港政府对香港机场的海天码头（就是要从广东或澳门坐船）到香政府对香港机场的海天码头',
              itemClass: 'textellipsis-2'
            }],
            itemClass: 'tag-display grey p-minor size'
          },
          {
            img: {
              src: '/images/cat.png',
              itemClass: 'pic-120 br-sm',
              mode: 'scaleToFill'
            },
            itemClass: 'ml-minor'
          },
        ],
        footer: [
          {
            title: [
              {
                img: {
                  src: '/images/cat.png',
                  mode: 'scaleToFill',
                  itemClass: 'pic-50 br-circle'
                }
              },
              {title: '华哥', itemClass: 'ml10'}
            ],
            titleClass: 'flex-row-start-center'
          },
          {
            title: [
              {title: '#酒店 #机票', itemClass: 'color-primary'},
              {title: '389', itemClass: 'icon-before-like icon-before-ml ml40 color-grey'}
            ],
            titleClass: 'flex-row-start-center',
          }
        ],
        bodyClass: 'flex-row-between mt-primary mb-default',
        footerClass: 'flex-row-between-center color-default',
        itemClass: 'ss-card',
      }]
    }
  })
}

const listAdaper = (data) => {
  return data.map((item, ii) => {
    return {
      '@list': {
        data: adpater([1,2,3]),
        listClass: 'size-form abc',
        itemClass: 'p-default',
        type: {
          is: 'scroll',
          'scroll-y': true
        },
        header: {
          title: [
            {title: '2021-03-1'+ (6 + ii) , itemClass: 'size-title-lg p-title-line-x color-title'},
            ii === 0 ? {title: '昨天', itemClass: 'size-sm color-grey'} : ''
          ],
          titleClass: 'flex-row-between-center hei-title color-grey'
        },
        footer: data.length !== (ii + 1) ? {
          title: ' ',
          itemClass: 'icon-goup size-title-lg ss-center color-grey'
        }: ''
      }
    }
  })
}

// const xx = defaultAdapter({title: '提交成功', desc: '发票开具中，请耐心等候', image: '/images/cat.png', cancel: true, cancelText: '返回首页', confirm: true,})
// const xx2 = defaultAdapter({title: '找不到此产品', image: '/images/cat.png', cancel: true, cancelText: '返回首页'})
// const xx3 = defaultAdapter({title: '网络错误', image: '/images/cat.png', cancel: true, cancelText: '返回首页', confirm: true,})

Pager({
  data: {
    pages: Pager.list({
      data: listAdaper([1,2,3]),
      listClass: 'demo',
      itemClass: 'demo-item',
      type: {
        is: 'swiper',
        // 'indicator-dots': true,
        vertical: true,
        interval: 2000,
        duration: 500
      }
    })
  },
  onJump(e, params, inst) {
    const type = params.type
    wx.navigateTo({
      url: '../'+type+'/index'
    })
  },
  onShow: function () {},
  onReady: function () {},
  onLoad: function () {},
})
